package com.design.movieticket.service.Impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.design.movieticket.entity.MovieHall;
import com.design.movieticket.mapper.MovieHallMapper;
import com.design.movieticket.service.MovieHallService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

@Service
public class MovieHallServiceImpl extends ServiceImpl<MovieHallMapper, MovieHall> implements MovieHallService {
    @Resource
    private MovieHallMapper movieHallMapper;

    /** 获取影院影厅列表 */
    @Override
    public List<MovieHall> getMovieHallListByCinemaId(long id) {
        return movieHallMapper.getMovieHallListByCinemaId(id);
    }

    /** 新增或更新影厅数据 */
    @Override
    public void addOrUpdateMovieHallInfo(MovieHall movieHall) {
        super.saveOrUpdate(movieHall);
    }

    /** 获取影厅信息详情 */
    @Override
    public MovieHall getMovieHallDetail(long id) {
        return super.getById(id);
    }

    /** 删除影厅信息 */
    @Override
    public void delMovieHallById(long id) {
        super.removeById(id);
    }

    /** 更改影厅状态 */
    @Override
    public void changeMovieHallStatus(long id) {
        int status = 0;
        if (super.getById(id).getStatus()==0){
            status = 1;
        }
        movieHallMapper.changeMovieHallStatus(id, status);
    }
}
